package com.example.demo.rocketmq.provider.service.impl;

import com.example.demo.rocketmq.provider.service.AbstractCommonProviderService;
import com.example.demo.rocketmq.vo.OrderChange;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.stereotype.Service;


@Service
public class OrderService extends AbstractCommonProviderService {

    public OrderService(RocketMQTemplate rocketMQTemplate) {
        super(rocketMQTemplate);
        setBeanName(OrderService.class.getSimpleName());
    }

    public void sendMessage(String msg) {
        super.send(msg);
    }

    public void sendOnewayMessage(String msg) {
        super.sendOneWay(msg);
    }

    public void sendTransactionMessage(OrderChange msg) {
        super.sendHalfmessafe("change", "com.example.demo.rocketmq.vo.OrderChange", msg);
    }

    /**
     * 回调方法-执行本地事务
     *
     * @param msg
     */
    public void change(OrderChange msg) {
        //业务逻辑
        System.out.println(msg.toString());
    }


}
